package com.example.day_blog.model;

import com.example.day_blog.common.Constants;
import lombok.Data;

/**
 * @author starsea
 * @date 2024-01-18 13:37
 */
@Data
public class Result<T> {
    private Integer code;
    //200成功-1表示失败
    private T data;
    private  String errMsg;
    //错误信息
    public static <T> Result<T> success(T data)
    {
        Result result=new Result();
        result.setCode(Constants.RESULT_SUCCESS);
        result.setData(data);
        return result;
    }
    public static <T> Result<T> fial(String errmsg)
    {
        Result result=new Result();
        result.setCode(Constants.RESULT_FAIL);
        result.setErrMsg(errmsg);
        return result;
    }
    public static <T> Result<T> fial(String errmsg,T data)
    {
        Result result=new Result();
        result.setCode(Constants.RESULT_FAIL);
        result.setData(data);
        result.setErrMsg(errmsg);
        return result;
    }
}
